Imports

In [69]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import mplfinance as mpf
import matplotlib.dates as mdates
import datetime as dt

import plotly.graph_objects as go
import plotly.express as px
import plotly.io as pio
from plotly.subplots import make_subplots

pio.renderers.default = "notebook"
pio.templates.default = "plotly_dark"
import gc

np.random.seed(42)
In [70]:
import warnings

warnings.filterwarnings("ignore")
In [71]:
plt.rcParams["figure.figsize"] = [12, 8]

Topics cum Notes

L10

Inverted Yield Curve

An inverted yield curve is a situation in which short term interest rates, like overnight rates or three month rates, are above long term interest rates. Inverted yield curves have often heralded a recession.

In [72]:
three_m = pd.read_csv("Data/3M.csv", index_col="Date", parse_dates=True)
six_m = pd.read_csv("Data/6M.csv", index_col="Date", parse_dates=True)
ten_y = pd.read_csv("Data/10Y.csv", index_col="Date", parse_dates=True)
thirty_y = pd.read_csv("Data/30Y.csv", index_col="Date", parse_dates=True)

us_13_w = pd.read_csv("Data/US13W.csv", index_col="Date", parse_dates=True)
us_10_y = pd.read_csv("Data/US10Y.csv", index_col="Date", parse_dates=True)
us_5_y = pd.read_csv("Data/US5Y.csv", index_col="Date", parse_dates=True)
us_30_y = pd.read_csv("Data/US30Y.csv", index_col="Date", parse_dates=True)
In [73]:
fig = go.Figure()

fig.add_scatter(
    x=us_30_y.index,
    y=us_30_y["Close"],
    name="US 30 Year Treasury Yield",
    line=dict(color="red", width=1),
)

fig.add_scatter(
    x=us_10_y.index,
    y=us_10_y["Close"],
    name="US 10 Year Treasury Yield",
    line=dict(color="blue", width=1),
)

fig.add_scatter(
    x=us_5_y.index,
    y=us_5_y["Close"],
    name="US 5 Year Treasury Yield",
    line=dict(color="green", width=1),
)

# fig.add_scatter(
#     x=us_13_w.index,
#     y=us_13_w["Close"],
#     name="US 13 Week Treasury Yield",
#     line=dict(color="yellow", width=1),
# )

fig.update_layout(
    title="US Treasury Yield Curve",
    xaxis_title="Date",
    yaxis_title="Yield",
    font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
fig.show()
In [74]:
thirty_y.sort_index(inplace=True, ascending=True)
In [75]:
thirty_y = thirty_y.drop_duplicates()
In [76]:
fig = go.Figure()


fig.add_scatter(
    x=six_m.index,
    y=six_m["Close"],
    name="6M",
    line=dict(color="green", width=1),
)

fig.add_scatter(
    x=ten_y.index,
    y=ten_y["Close"],
    name="10Y",
    line=dict(color="blue", width=1),
)

fig.add_scatter(
    x=thirty_y.index,
    y=thirty_y["Close"],
    name="30Y",
    line=dict(color="white", width=1),
)

fig.update_layout(
    title="Indian Treasury Yield Curve",
    xaxis_title="Date",
    yaxis_title="Yield",
    font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
fig.show()
In [77]:
data = [us_5_y["Close"][4910], us_10_y["Close"][4910],  us_30_y["Close"][4910]]
labels = ["US 5Y", "US 10Y", "US 30Y"]

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=labels,
        y=data,
        marker_color=["blue", "green", "red"],
        name="US Treasury Yield",
    )
)
fig.update_layout(
    title=f"US Treasury Yield Curve on {us_5_y.iloc[4910].name.strftime('%Y-%m-%d')}",
    xaxis_title="Date",
    yaxis_title="Yield",
    font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
In [78]:
data = [three_m["Close"][-1],  six_m["Close"][-1], ten_y["Close"][-1], thirty_y["Close"][-1] ]
labels = ["3M", "6M", "10Y", "30Y"]

fig = go.Figure()
fig.add_trace(
    go.Scatter(
        x=labels,
        y=data,
        marker_color=["blue", "green", "red", "yellow"],
        name="Indian Treasury Yield",
    )
)
fig.update_layout(
    title="Indian Treasury Yield Curve",
    xaxis_title="Time",
    yaxis_title="Yield",
    font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)

fig.show()

LIBOR-OIS Spread

The LIBOR-OIS spread represents the difference between an interest rate with some credit risk built-in and one that is virtually free of such hazards. Therefore, when the gap widens, it’s a good sign that the financial sector is on edge.

Mortgage

We have it as a verb. To mortgage something, to mortgage your house means to offer it as collateral for a loan. So when you get a mortgage on your house, typically it is to buy the house, the bank lends you the money to buy the house, but if you stop paying on the mortgage, they can reclaim the house.

Underwater: The term underwater is used to describe a situation in which the value of a home is less than the amount of money owed on the mortgage. If you are underwater, you are in a negative equity situation.

Commercial Real Estate Vehicles

Real Estate

Not everyone can invest in real state. You must be "wealthy enough" to do so. The reason is that real estate is a very illiquid asset. It is very hard to sell at a price that you want. So, if you are a wealthy person, you can afford to buy a house and hold it for a long time. If you are not wealthy, you cannot afford to buy a house and hold it for a long time. You need to be able to sell it quickly if you need to.

Real Estate Investment Trust (REIT)

Limited Partnership

Direct Participation Program (DPP)

In [79]:
m_15_us = pd.read_csv("Data/MORTGAGE15US.csv", index_col="DATE", parse_dates=True)
m_30_us = pd.read_csv("Data/MORTGAGE30US.csv", index_col="DATE", parse_dates=True)
In [80]:
fig = go.Figure()

fig.add_scatter(
    x=m_15_us.index,
    y=m_15_us["MORTGAGE15US"],
    name="15 Year Mortgage Rate",
    line=dict(color="red", width=1),
)

fig.add_scatter(
    x=m_30_us.index,
    y=m_30_us["MORTGAGE30US"],
    name="30 Year Mortgage Rate",
    line=dict(color="blue", width=1),
)

fig.update_layout(
    title="US Mortgage Rate",
    xaxis_title="Date",
    yaxis_title="Rate",
    font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
fig.show()

Amortization

Amortization means, paying off the principal. Your payment comes in two parts. One of them is interest. One of them is amortization.

Kind of Mortgages

Here are some of the most common types of mortgages:

  • Fixed-rate mortgage: A fixed-rate mortgage is a mortgage loan where the interest rate on the note remains the same through the term of the loan, as opposed to loans where the interest rate may adjust or "float". Typically, a fixed-rate mortgage has a term of 15 or 30 years.
  • Adjustable Rate Mortgage: An adjustable rate mortgage (ARM) is a type of mortgage in which the interest rate applied on the outstanding balance varies throughout the life of the loan. An ARM is typically issued with an introductory period where the interest rate is fixed, after which the interest rate becomes variable. The interest rate is adjusted periodically based on a pre-determined index. The index is typically the London Interbank Offered Rate (LIBOR). The margin is the fixed amount of interest rate that is added to the index to determine the interest rate on the loan. The margin is usually between 2.25% and 3.0%.
  • Price Level Adjusted Mortgage: A price level adjusted mortgage (PLAM) is a type of adjustable rate mortgage (ARM) in which the interest rate is adjusted based on the change in the Consumer Price Index (CPI). The interest rate is adjusted periodically based on the change in the CPI. The interest rate is adjusted by the change in the CPI plus a margin. The margin is the fixed amount of interest rate that is added to the change in the CPI to determine the interest rate on the loan. The margin is usually between 2.25% and 3.0%.
  • Shared Appreciation Mortgages: A shared appreciation mortgage (SAM) is a type of adjustable rate mortgage (ARM) in which the interest rate is adjusted based on the change in the value of the property. The interest rate is adjusted periodically based on the change in the value of the property. The interest rate is adjusted by the change in the value of the property plus a margin. The margin is the fixed amount of interest rate that is added to the change in the value of the property to determine the interest rate on the loan. The margin is usually between 2.25% and 3.0%.

Private Mortgage Insurance (PMI)

PMI is a type of insurance you might be required to pay for if you have a conventional loan and make a down payment that is less than 20 percent of the home’s purchase price. PMI protects the lender on a conventional mortgage in the event that the borrower defaults and the lender is forced to foreclose.

Centralized Mortgage Obligation (CMO)

Tranch and A-Ratings?

Centralized Debt Obligation (CDO)

Excess Reserves

Reserve requirements that banks have to keep a certain amount of cash on reserve to meet any sudden increase in demand from their depositors.

Excess reserves are the reserves that banks hold beyond what they're required to hold by regulation.

Real Estate Bubble

L11

Regulation and Human Behavior

Usually, homeowners are better citizens and hence tax policy encourages home ownership.

Dodd-Frank Act

Levels of Financial Regulation

  1. Within-firm Regulation
  2. Trade Groups
  3. Local Government Regulation
  4. National Government Regulation
  5. International Regulation

Tunneling

The word tunneling is often used to describe tricks that people in companies use to steal money from the company.

This can be achieved by:

  • Asset Sales
  • Contracts (Buy service on more than market value)
  • Loan Guarantees
  • Dilutive Share Isuue
  • Insider Trading

Hedge Funds

They are private institutes which are mainly for wealthy investors. All the investors should be "accredited investors" (In US this means that they must have income of at least $200,000 or investable assets of $2,500,000). This form the "3c1" kind of gendge fund where maximum number of investors is 99.

The "3c7"s are the hedge funds which can have at most 500 "qualified purchasers" (individuals with net worth greater than $5 Million or institutions with net worth greater than $25 Million).

This was defined in 2006.

Public and Private Securities

Usually, a company starts as private and then becomes public through an IPO. The company must be approved by the SEC to go public. The reverse of this is also possible.

Insiders and Outsiders

Insiders are people with special knowledge because of connections about a company. Inside information represents wealth. If you know something that the general investing public doesn't know, that's an opportunity for you to trade on that information.

Front Running

Front running is a form of market manipulation in which a broker, investment advisor, or trader executes orders ahead of the client's order, based on the client's order. This is illegal.

Generally Accepted Accounting Principles (GAAP)

GAAP is a set of accounting standards that companies must follow when they report their financial statements to the public. The SEC requires that companies follow GAAP when they report their financial statements to the public.